import { IPSAppCounterRef } from '../../app/control/ipsapp-counter-ref';
import { IPSDETabViewPanel } from './ipsdetab-view-panel';
import { PSDEViewPanelImpl } from './psdeview-panel-impl';
import { IPSDERBase } from '../../dataentity/der/ipsderbase';
import { IPSDEOPPriv } from '../../dataentity/priv/ipsdeoppriv';
import { IPSSysImage } from '../../res/ipssys-image';

export class PSDETabViewPanelImpl extends PSDEViewPanelImpl implements IPSDETabViewPanel {
  get counterId(): string {
    return this.M.counterId;
  }

  get navFilter(): string {
    return this.M.navFilter;
  }

  protected navpsder: IPSDERBase | null = null;

  getNavPSDER(): IPSDERBase | null {
    if (this.navpsder != null) return this.navpsder;
    const value = this.M.getNavPSDER;
    if (value == null) {
      return null;
    }
    this.navpsder = this.getPSModel4('dataentity.der.IPSDERBase', value, 'getNavPSDER') as IPSDERBase;
    return this.navpsder;
  }

  get navPSDER(): IPSDERBase | null {
    return this.getNavPSDER();
  }

  getNavPSDERMust(): IPSDERBase {
    const value = this.getNavPSDER();
    if (value == null) {
      throw new Error('未指定导航关系对象');
    }
    return value;
  }

  protected psappcounterref: IPSAppCounterRef | null = null;

  getPSAppCounterRef(): IPSAppCounterRef | null {
    if (this.psappcounterref != null) return this.psappcounterref;
    const value = this.M.getPSAppCounterRef;
    if (value == null) {
      return null;
    }
    this.psappcounterref = this.getPSModel4('app.control.IPSAppCounterRef', value, 'getPSAppCounterRef') as IPSAppCounterRef;
    return this.psappcounterref;
  }

  get psAppCounterRef(): IPSAppCounterRef | null {
    return this.getPSAppCounterRef();
  }

  getPSAppCounterRefMust(): IPSAppCounterRef {
    const value = this.getPSAppCounterRef();
    if (value == null) {
      throw new Error('未指定应用计数器引用');
    }
    return value;
  }

  protected psdeoppriv: IPSDEOPPriv | null = null;

  getPSDEOPPriv(): IPSDEOPPriv | null {
    if (this.psdeoppriv != null) return this.psdeoppriv;
    const value = this.M.getPSDEOPPriv;
    if (value == null) {
      return null;
    }
    this.psdeoppriv = this.getPSModel4('dataentity.priv.IPSDEOPPriv', value, 'getPSDEOPPriv') as IPSDEOPPriv;
    return this.psdeoppriv;
  }

  get psDEOPPriv(): IPSDEOPPriv | null {
    return this.getPSDEOPPriv();
  }

  getPSDEOPPrivMust(): IPSDEOPPriv {
    const value = this.getPSDEOPPriv();
    if (value == null) {
      throw new Error('未指定访问操作标识');
    }
    return value;
  }

  protected pssysimage: IPSSysImage | null = null;

  getPSSysImage(): IPSSysImage | null {
    if (this.pssysimage != null) return this.pssysimage;
    const value = this.M.getPSSysImage;
    if (value == null) {
      return null;
    }
    this.pssysimage = this.getPSModel4('res.IPSSysImage', value, 'getPSSysImage') as IPSSysImage;
    return this.pssysimage;
  }

  get psSysImage(): IPSSysImage | null {
    return this.getPSSysImage();
  }

  getPSSysImageMust(): IPSSysImage {
    const value = this.getPSSysImage();
    if (value == null) {
      throw new Error('未指定标题图标');
    }
    return value;
  }

  get parentDataJO(): IModel {
    return this.M.parentDataJO;
  }

  get cls(): string {
    return 'PSDETabViewPanelImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.expbar.IPSTabExpPage' || cls == 'control.viewpanel.IPSDETabViewPanel') return true;
    return super.instanceof(cls);
  }
}
